using UnityEngine;
using System.Collections;

public class QuitApplication : MonoBehaviour 
{
	int currentLevel;
    public string backLevel;
	
	void Start ()
    {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
	}
	
	void Update () 
	{
		currentLevel = Application.loadedLevel;
		
		if(Input.GetKeyDown(KeyCode.Escape))
		{
            if (Application.loadedLevelName == "Menu")
            {
                Application.Quit();
            }
            else
            {
                Application.LoadLevel(backLevel);
            }
		}
	}
}
